from itsdangerous import TimedJSONWebSignatureSerializer as Serializer, BadData
from django.conf import settings
def openid_encode(openid):
    """放入需要加密的数据"""
    serializer = Serializer(settings.SECRET_KEY,600)
    data = serializer.dumps({"openid":openid})
    return data.decode()

def openid_decode(openid):
    """放入需要解密的数据"""
    serializer = Serializer(settings.SECRET_KEY, 600)
    data = serializer.loads(openid)
    return data.get("openid",None)